home *** CD-ROM | disk | FTP | other *** search
- Path: news.netgate.net!news
- From: Tamara Johnson <malihini@netgate.net>
- Newsgroups: comp.lang.c
- Subject: ?Help - struct array of strings
- Date: 10 Mar 1996 23:44:25 GMT
- Organization: NetGate Communications
- Message-ID: <4hvpgp$gu7@ftp.netgate.net>
- NNTP-Posting-Host: d49.netgate.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- /*
- program to enter author(s), title(s)
- then display entries.
- why is printf displaying strange things?
- (see output at end)
- */
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
-
- #define MAX 5
-
- struct catalog{
- char name[80]; /* author name */
- char title[80]; /* title */
- }cat[80];
-
- void main()
-
- {
- int i;
-
- for(i=0;i<MAX;i++)
- {
- printf("Enter author name (ENTER to quit); ");
- gets(cat[i].name);
- if(!*cat[i].name) break;
- printf("Enter title: ");
- gets(cat[i].title);
- }
- for(i=0;i<MAX;i++)
- printf("%c %c\n", cat[i].name, cat[i].title);
- }
- /*
- output;
-
- Enter author name (ENTER to quit); tom
- Enter title: pickled peppers
- Enter author name (ENTER to quit); sam
- Enter title: hop on pop
- Enter author name (ENTER to quit);
- ` t
- Ω ú
- _ -
- + _
- ╢
- */
-
-